import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

const routes = [
		{
			path: '*',
			redirect: '/game_hall'
		},{
			name: 'game_hall',
			path: '/game_hall',
			component: () => import('@/view/Game/game_hall.vue'),
			meta: { title: '游戏大厅页面' }
		},{
			name: 'game_room',
			path: '/game_room',
			component: () => import('@/view/Game/game_room.vue'),
			meta: { title: '游戏大厅页面' }
		},{
			name: 'user_login',
		    path: '/user_login',
			component: () => import('@/view/Login/user_login.vue'),
			meta: { title: '玩家登录页面' }
		},{
			name: 'user_register',
			path: '/user_register',
			component: () => import('@/view/Login/user_register.vue'),
			meta: { title: '玩家注册页面' }
		},{
			name: 'friend_index',
			path: '/friend_index',
			component: () => import('@/view/Friend/friend_index.vue'),
			meta: { title: '我的好友' }
		},{
			name: 'user_center',
			path: '/user_center',
			component: () => import('@/view/UserCenter/user_center.vue'),
			meta: { title: '个人中心' },
		},{
			name: 'service_testing',
			path: '/user_center/menu/service_testing',
			component: () => import('@/view/UserCenter/Menu/service_testing.vue'),
			meta: { title: '游戏环境测试' }
		},{
			name: 'goods',
			path: '/goods',
			component: () => import('@/view/goods/index.vue'),
			meta: { title: '玩家注册页面' }
		},
	];
const router = new Router({ routes });

router.beforeEach((to, from, next) => {
	const title = to.meta && to.meta.title;
	if (title) {
		document.title = title;
	}
	next();
});

export { router };